package com.netease.dragonwar.sprite;

import java.awt.image.BufferedImage;

import com.netease.dragonwar.common.GameDirectionEnum;
import com.netease.dragonwar.util.ImageUtils;

/**
 * @author louxj424
 * @version 0.1.0
 * @date 创建时间：2018年3月5日 上午10:22:57
 * @since jdk 1.7.0
 */
public class Bullet extends Sprite {

	/**
	 * 子弹的方向
	 */
	private GameDirectionEnum direction;

	/**
	 * 存放子弹图片的数组
	 */
	private BufferedImage[] imgs = ImageUtils.getBulletImages();

	public Bullet(int x, int y, int width, int height, int speed, GameDirectionEnum direction) {
		super(x, y, width, height, speed);
		this.direction = direction;
	}

	@Override
	public void move() {
		switch (direction) {
		case DIRECTION_UP:
			setY(getY() - getSpeed());
			break;
		case DIRECTION_RIGHT:
			setX(getX() + getSpeed());
			break;
		case DIRECTION_DOWN:
			setY(getY() + getSpeed());
			break;
		case DIRECTION_LEFT:
			setX(getX() - getSpeed());
			break;
		}
	}

	@Override
	public BufferedImage getImage() {
		return imgs[direction.getCode()];
	}

}
